package com.skyline.myspider.schedule;

import java.util.List;

public class RelevanceValider {
	private static boolean valide = false;
	private static List<String> keywords;

	public static void addKeywords(List<String> keywords) {
		RelevanceValider.keywords = keywords;
		if (keywords == null || keywords.size() == 0) {
			RelevanceValider.valide = false;
		} else {
			RelevanceValider.valide = true;
		}
	}

	public static float valide(String inHtml) {
		String html=inHtml.toLowerCase();
		float relevance = 0;
		if (RelevanceValider.valide == false) {
			return 1;
		}
		else{
			for(int i=0;i<keywords.size();i++){
				if(html.contains(keywords.get(i))){
					relevance+=1;
				}
			}
			relevance=relevance/keywords.size();
			return relevance;
		}
	}
}
